package secretary;

import java.sql.SQLException;

import basic.ClientConsole;

import com.sun.rowset.CachedRowSetImpl;
import flexibility.userData;

//this class will get semester for edit details and return the real semester id
public class defineSemester {

	userData semesterData = new userData();
	public int identify(int semester, ClientConsole secretaryConnection, CachedRowSetImpl crs){
		switch(semester){
		case 1://next
			semesterData.deleteAll();
			semesterData.addData(15);
			semesterData.addData(1);
			secretaryConnection.acceptMsg(semesterData);
			crs = secretaryConnection.getResults();
			try {
				crs.next();
				semester = Integer.parseInt(crs.getString(1));
			} catch (SQLException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			break;
		case 0://current
			semesterData.deleteAll();
			semesterData.addData(82);
			semesterData.addData(1);
			secretaryConnection.acceptMsg(semesterData);
			crs = secretaryConnection.getResults();
			try {
				crs.next();
				semester = Integer.parseInt(crs.getString(1));
			} catch (SQLException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		break;
		}
		return semester;
	}
}
